<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">

    <title>Dynamic Table</title>

    <!--dynamic table-->
    <link href="/public/js/advanced-datatable/css/demo_page.css" rel="stylesheet" />
    <link href="/public/js/advanced-datatable/css/demo_table.css" rel="stylesheet" />
    <link rel="stylesheet" href="/public/js/data-tables/DT_bootstrap.css" />
    <?php $this->load->view('library/header');?>
</head>

<body class="sticky-header">

<section>

    <?php $this->load->view('library/left');?>

    <!-- main content start-->
    <div class="main-content" >

        <?php $this->load->view('library/top');?>

        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                E站搜索下架sku
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">Dashboard</a>
                </li>
                <li>
                    <a href="#">Data Tables</a>
                </li>
                <li class="active"> Dynamic Table </li>
            </ul>
        </div>
        <!-- page heading end-->

        <!--body wrapper start-->
        <div class="wrapper">
            <div class="row">
                <div class="col-sm-12">
                    <?php $this->load->view('library/search');?>
                    <section class="panel">
                        <div class="panel-body">
                            <div class="adv-table">
                                <table  class="display table table-bordered table-striped" id="dynamic-table">
                                    <thead>
                                    <tr>
                                        <th width="2%">#</th>
                                        <th width="4%">商品货号</th>
                                        <th width="5%" class="center" >商品图片</th>
                                        <th width="5%" class="hidden-phone">状态</th>
                                        <!-- <th width="5%" class="hidden-phone">供应商</th>
                                        <th width="5%" class="hidden-phone">采购数量</th>
                                        <th width="5%" class="hidden-phone">入库数量</th>
                                        <th width="5%" class="hidden-phone">采购总额</th>
                                        <th width="5%" class="hidden-phone">采购状态</th>
                                        <th width="5%" class="hidden-phone">采购批次</th>
                                        <th width="5%" class="hidden-phone">生成时间</th> -->
                                        <th width="5%" class="hidden-phone">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php foreach ($goods_list as $item): ?>
                                        <tr class="gradeX">
                                            <td><?php echo $item['sku_id'];?></td>
                                            <td><?php echo $item['sku_sn'];?></td>
                                            <td class="center"><img style="width: 60px;" src="<?php echo $item['original_img'];?>" /></td>
                                            <td class="center hidden-phone"><?php echo $item['is_on_sale'] == 1 ? '上架' : '下架'?></td>
                                            <td class="hidden-phone">
                                                <button class="btn btn-info import-ajax" data-id="<?php echo $item['sku_id'];?>" type="submit">
                                                    <?php echo $item['is_on_sale'] == 1 ? '下架' : '上架'?>
                                                </button>
                                            </td>
                                            <!-- <td class="center hidden-phone"><?php echo $item['pg_number'];?></td>
                                            <td class="center hidden-phone"><?php echo $item['inv_number'];?></td>
                                            <td class="center hidden-phone"><?php echo $item['purc_price'];?></td>
                                            <td class="center hidden-phone">
                                                <?php if ($item['pg_status'] == 1):?>
                                                    等待采购
                                                <?php elseif($item['pg_status'] == 2) :?>
                                                    采购中
                                                <?php elseif($item['pg_status'] == 3) :?>
                                                    采购完成
                                                <?php elseif($item['pg_status'] == 4) :?>
                                                    取消采购
                                                <?php else:?>
                                                    未采购
                                                <?php endif;?>
                                            </td>
                                            <td class="center hidden-phone"><?php echo $item['po_sn'] ? $item['po_sn'] : '无';?></td>
                                            <td class="center hidden-phone"><?php echo date('Y-m-d H:i:s', $item['add_time']);?></td>
                                            <td class="hidden-phone"><a href="">查看</a></td> -->
                                        </tr>
                                    <?php endforeach;?>
                                    </tbody>
                                </table>
                                <button class="btn btn-info import-ajax-all" data-id="<?php echo $param['goods_id'];?>" type="submit">
                                    全部下架
                                </button>
                            </div>
                            <div class="row-fluid">
                                <div class="span6">
                                    <div class="dataTables_paginate paging_bootstrap pagination">
                                        <ul>
                                            <?php echo $pages;?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </div>
        <!--body wrapper end-->

        <!--footer section start-->
        <footer>
            2014 &copy; AdminEx by
        </footer>
        <!--footer section end-->


    </div>
    <!-- main content end-->
</section>

<?php $this->load->view('library/footer');?>

<!--dynamic table-->
<!--<script type="text/javascript" language="javascript" src="/public/js/advanced-datatable/js/jquery.dataTables.js"></script>-->
<!--<script type="text/javascript" src="/public/js/data-tables/DT_bootstrap.js"></script>-->
<!--dynamic table initialization -->
<!--<script src="/public/js/dynamic_table_init.js"></script>-->

<!--common scripts for all pages-->
<script src="/public/js/scripts.js"></script>

</body>
</html>
<script>
    $(".import-ajax").on("click", function () {
    var _this = $(this);

    swal({
            title: '修改商品sku状态',
            showCancelButton: true,
            preConfirm: function preConfirm(value) {
                var id = _this.data('id');
                swal({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });
                return $.post("<?php echo base_url('Purchase/goods_up_sku');?>", {id: id}, function (data) {
                    return data;
                },'json');
            }
        }).then(function (result) {
            if (result.value) {
                var data = result.value;
                swal({
                    type: data.status,
                    title: data.info
                }).then(function(isConfirm) {
                    location.reload();
                });
            }
        });

        return false;
    });
    
    $(".import-ajax-all").on("click", function () {
        
        var _this = $(this);

        swal({
            title: '下架商品',
            showCancelButton: true,
            preConfirm: function preConfirm(value) {
                var goods_id = _this.data('id');
                swal({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });
                return $.post("<?php echo base_url('Purchase/goods_up');?>", {goods_id: goods_id}, function (data) {
                    return data;
                },'json');
            }
        }).then(function (result) {
            if (result.value) {
                var data = result.value;
                swal({
                    type: data.status,
                    title: data.info
                }).then(function(isConfirm) {
                    location.reload();
                });
            }
        });

        return false;
    });
</script>
